package com.project.server.service.operate.impl;

import com.project.common.core.domain.BaseServer;
import com.project.server.domain.operate.TOperateAffair;
import com.project.server.domain.operate.TOperateEmergency;
import com.project.server.mapper.operate.TOperateAffairMapper;
import com.project.server.service.operate.ITOperateAffairService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

import static com.project.server.utils.DelTagUtil.getTextFromHtml;

/**
 * 运营管理办事指南Service业务层处理
 *
 * @author project
 * @date 2021-07-01
 */
@Service
public class TOperateAffairServiceImpl extends BaseServer implements ITOperateAffairService {

    private static final Logger log = LoggerFactory.getLogger(TOperateAffairServiceImpl.class);

    @Resource
    private TOperateAffairMapper tOperateAffairMapper;

    /**
     * 查询运营管理办事指南
     *
     * @param affairId 运营管理办事指南ID
     * @return 运营管理办事指南
     */
    @Override
    public TOperateAffair selectTOperateAffairById(Long affairId) {
        return tOperateAffairMapper.selectTOperateAffairById(affairId);
    }

    /**
     * 查询运营管理办事指南列表
     *
     * @param tOperateAffair 运营管理办事指南
     * @return 运营管理办事指南
     */
    @Override
    public List<TOperateAffair> selectTOperateAffairList(TOperateAffair tOperateAffair) {
        return tOperateAffairMapper.selectTOperateAffairList(tOperateAffair);
    }

    /**
     * 处理导出内容中的html标签
     */
    @Override
    public  List<TOperateAffair> selectTOperateAffairDelTags(TOperateAffair tOperateAffair){
        List<TOperateAffair> operateAffairs = tOperateAffairMapper.selectTOperateAffairList(tOperateAffair);
        for(int i = 0;i<operateAffairs.size();i++){
            TOperateAffair tOperateAffair1 = operateAffairs.get(i);
            tOperateAffair.setAffairDetails(getTextFromHtml(tOperateAffair1.getAffairDetails()));
        }
        return operateAffairs;
    }

    /**
     * 新增运营管理办事指南
     *
     * @param tOperateAffair 运营管理办事指南
     * @return 结果
     */
    @Override
    public int insertTOperateAffair(TOperateAffair tOperateAffair) {
        super.insert(tOperateAffair);
        return tOperateAffairMapper.insertTOperateAffair(tOperateAffair);
    }

    /**
     * 修改运营管理办事指南
     *
     * @param tOperateAffair 运营管理办事指南
     * @return 结果
     */
    @Override
    public int updateTOperateAffair(TOperateAffair tOperateAffair) {
        super.update(tOperateAffair);
        return tOperateAffairMapper.updateTOperateAffair(tOperateAffair);
    }

    /**
     * 批量删除运营管理办事指南
     *
     * @param affairIds 需要删除的运营管理办事指南ID
     * @return 结果
     */
    @Override
    public int deleteTOperateAffairByIds(Long[] affairIds) {
        return tOperateAffairMapper.deleteTOperateAffairByIds(affairIds);
    }

    /**
     * 删除运营管理办事指南信息
     *
     * @param affairId 运营管理办事指南ID
     * @return 结果
     */
    @Override
    public int deleteTOperateAffairById(Long affairId) {
        return tOperateAffairMapper.deleteTOperateAffairById(affairId);
    }
}
